Use case: Disable and enable write protection

Note

The HAL1 API name for disabling write operations has been renamed to write protection enable in HAL2.

Sequence diagram

Disable and enable write protection

@startuml

== Prerequisite: Initialization and configuration ==

== Process ==

"User Application" -> "HAL SRAM Driver" : HAL_SRAM_WriteOperation_Enable()
note over "HAL SRAM Driver"
   **Enable write operation**
   **to perform write operations**
end note

"User Application" -> "HAL SRAM Driver" : Write operations

"User Application" -> "HAL SRAM Driver" : HAL_SRAM_WriteOperation_Disable()
note over "HAL SRAM Driver"
   **Disable write operation**
   **to prevent any write operation**
end note

@enduml

Code snippet

HAL1

HAL2

/* Enable write operation */
HAL_SRAM_WriteOperation_Enable(&hsram);

/* Do some write operations if needed */

/* Disable write operation */
HAL_SRAM_WriteOperation_Disable(&hsram);
/* Disable the Write protection */
HAL_SRAM_DisableWriteProtection(&hsram);

/* Do some write operations if needed */

/* Enable the Write protection */
HAL_SRAM_EnableWriteProtection(&hsram);

Key changes

  1. HAL2 uses explicit write protection APIs (enable/disable write protection).

  2. HAL1 enables/disables write operations using HAL_SRAM_WriteOperation_Enable()/HAL_SRAM_WriteOperation_Disable().